package com.example.evanproject.controller;
import com.example.evanproject.service.ChatlistService;
import com.example.evanproject.service.impl.ChatlistServiceImpl;

import com.example.evanproject.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("chat")
public class Chatcontorller {

    @Autowired
    private ChatlistService chatService;


    /*根据用户id查询自己的聊天列表（并附带最后一条信息）*/
    @RequestMapping("selectbyid")
    public AjaxResult selectbyidlist(Integer userid){
        return AjaxResult.success(chatService.selectbyidlist(userid)) ;
    }

    /*查找两个用户之间的聊天记录*/
    @RequestMapping("chatrecord")
    public AjaxResult selectchatrecordsbytwoid(Integer userid1,Integer userid2){
 return AjaxResult.success(chatService.selectchatrecordsbytwoid(userid1,userid2)) ;
    }

    /*发送消息*/
@RequestMapping("sendid")
        public AjaxResult sendlist(Integer sendid,Integer toid,String message){
        return AjaxResult.success(chatService.sendlist(sendid,toid,message)) ;
    }
}
